<!-- 导航栏 -->
<template>
  <div class="nav-container">
    <header>
      <div class="main">
        <div class="left">
          <img src="@/assets/logo.png" alt="" class="logo" />
          <p class="title">宿舍管理</p>
        </div>
        <ul class="rigth">
          <li class="text">
            <router-link :to="{name:'home'}">首页</router-link>
          </li>
          <li class="text">
            <router-link class="avatar" :to="{name:'personal'}">
                <avatar :url="readUserInfo.avatar" :size="30" />
                <p>&nbsp;{{ readUserInfo.Nickname }}</p>
            </router-link>
          </li>
          <li class="text">
            <router-link :to="{name:'updata'}">修改信息</router-link>
          </li>
          <li class="text">
            <router-link :to="{name:'changePwd'}">修改密码</router-link>
          </li>
          <li class="text" @click="logOut">
            <a >退出</a>
          </li>
        </ul>
      </div>
        <img src="@/assets/left-top-logo.png" alt=""  class="top-logo"/>
        <img src="@/assets/right-bottom-logo.png" alt="" class="bottom-logo"/>
    </header>
   
  </div>
</template>

<script setup>
import {useRouter} from "vue-router"
import avatar from "@/components/Avatar/index.vue"
import {useUserStore} from "@/store/useUserStore.js"
import { storeToRefs } from "pinia";
const store = useUserStore()
const {readUserInfo} = storeToRefs(store)
const router = useRouter()
// 退出
function logOut(){
  localStorage.removeItem("token")
  sessionStorage.removeItem("token")
  sessionStorage.removeItem("userInfo")
  router.push({
    name: 'login'
  })
}

</script>

<style lang="less" scoped>
@import "@/styles/var.less";

.nav-container {
  width: 100%;
  height: 80px;
  line-height: 80px;
  background-color: rgba(28, 35, 39, 0.7);
  backdrop-filter: blur(5px);
  .main {
    width: 80%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      flex: 1;
      display: flex;
      align-items: center;
      img {
        width: 70px;
      }
      .title {
        font-weight: bold;
        font-size: 30px;
      }
    }
    .rigth {
      flex: 1;
      width: 100%;
      height: 50px;
      line-height: 50px;
      display: flex;
      justify-content: flex-end;
      .avatar{
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .text:first-child {
        margin-left: 0px;
      }
      .text:last-child {
        margin-right: 0px;
      }
      .text {

        margin: 0 20px;
        cursor: pointer;
        &::after {
          content: "";
          display: block;
          width: 0;
          background-color: @suspension;
          height: 3px;
          transition: all 0.5s ease 0s;
        }
        &:hover::after {
          width: 100%;
        }
        &:hover {
          color: @suspension;
        }
      }
    }
  }
  .top-logo{
    position: absolute;
    left: 0;
    top: 0px;
    animation: top-logos 5s linear infinite alternate;
  }
  .bottom-logo{
    position: absolute;
    left: 0px;
    top: 70px;
    animation: bottom-logos 5s linear infinite alternate;
  }
  @keyframes top-logos {
    0%{
        left:-500px
    }
    100%{
        left:100vw
    }
  }

  @keyframes bottom-logos {
    0%{
        left:100vw
       
    }
    100%{
        left:-500px
    }
  }
}
</style>